home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-214 dbase v for windows / 1.ima / MUSIC1.PAK / SEARCH.WFM < prev    next >
Encoding:
Text File  |  1994-08-02  |  6.9 KB  |  222 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Search.wfm
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         1/94
  7. *
  8. *  UPDATED:      6/94
  9. *
  10. *  REVISION:     $Revision:   1.21  $
  11. *
  12. *  VERSION:      dBASE FOR WINDOWS 5.0
  13. *
  14. *  DESCRIPTION:  This form allows setting a filter on the items currently
  15. *                viewed.  It allows you to create a combination filter based
  16. *                on the artist, title, price, release date, and media type
  17. *                of the available items from the Musical Methods store.
  18. *
  19. *  PARAMETERS:   None
  20. *
  21. *  CALLS:        Music.cc      (for custom pushbuttons)
  22. *                Music.prg     (procedure file)
  23. *
  24. *  USAGE:        DO Search.wfm  && or
  25. *
  26. *                local f
  27. *                set procedure to Search.wfm
  28. *                f = new SearchForm()
  29. *                f.ReadModal()
  30. *******************************************************************************
  31. #include <Messdlg.h>
  32. #include "Music.h"
  33. set talk off
  34. set ldcheck off
  35.  
  36. ** END HEADER -- do not remove this line*
  37. * Generated on 06/19/94
  38. *
  39. LOCAL f
  40. f = NEW SEARCHFORM()
  41. f.Open()
  42.  
  43. CLASS SEARCHFORM OF FORM
  44.    Set Procedure to Music.cc Additive
  45.    this.MousePointer =          1
  46.    this.ColorNormal = "R/W"
  47.    this.Width =         60.35
  48.    this.Top =          6.18
  49.    this.Text = "Search"
  50.    this.Left =         23.29
  51.    this.OnSelection = CLASS::ONSELECTION
  52.    this.Height =          8.71
  53.    this.Minimize = .F.
  54.    this.Maximize = .F.
  55.    this.OnOpen = CLASS::ONOPEN
  56.    this.HelpFile = ""
  57.    this.HelpId = ""
  58.  
  59.    DEFINE RECTANGLE SEARCHRECT OF THIS;
  60.        PROPERTY;
  61.          ColorNormal "w*/r",;
  62.          Width         57.97,;
  63.          Top          0.50,;
  64.          Text "",;
  65.          Left          1.19,;
  66.          Height          3.79,;
  67.          Border .T.,;
  68.          BorderStyle          1
  69.  
  70.    DEFINE NORMALTEXT FIELDTEXT OF THIS;
  71.        PROPERTY;
  72.          FontBold .F.,;
  73.          Alignment          5,;
  74.          ColorNormal "w*/r",;
  75.          Width         9.35,;
  76.          Top          1.01,;
  77.          Text "Field:",;
  78.          Left          1.87,;
  79.          Height          1.26,;
  80.          Border .F.
  81.  
  82.    DEFINE COMBOBOX FIELDCOMBO OF THIS;
  83.        PROPERTY;
  84.          Width         27.20,;
  85.          DataSource "STRUCTURE",;
  86.          Top          1.00,;
  87.          ID        800,;
  88.          Left         11.90,;
  89.          Value "",;
  90.          Height          1.18,;
  91.          Style          2,;
  92.          HelpFile "Music.hlp",;
  93.          HelpID "Search Field",;
  94.          StatusMessage "Select a field to search for.  Press F1 for Help."
  95.  
  96.    DEFINE NORMALTEXT VALUETEXT OF THIS;
  97.        PROPERTY;
  98.          FontBold .F.,;
  99.          Alignment          5,;
  100.          ColorNormal "w*/r",;
  101.          Width         9.35,;
  102.          Top          2.47,;
  103.          Text "Value:",;
  104.          Left          1.87,;
  105.          Height          1.24,;
  106.          Border .F.
  107.  
  108.    DEFINE NORMALENTRY VALUEENTRY OF THIS;
  109.        PROPERTY;
  110.          ColorNormal "R/W",;
  111.          StatusMessage "Enter a value to search for.  Press F1 for help.",;
  112.          Width         45.90,;
  113.          Top          2.47,;
  114.          Left         11.90,;
  115.          Value "                    ",;
  116.          Height          1.24,;
  117.          HelpFile "Music.hlp",;
  118.          HelpID "Search Value",;
  119.          Border .T.,;
  120.          ColorHighLight "R/W*",;
  121.          Enabled .T.,;
  122.          Function "!"
  123.  
  124.    DEFINE IMAGE LOGOIMAGE OF THIS;
  125.        PROPERTY;
  126.          Alignment          2,;
  127.          Width         10.71,;
  128.          DataSource "FILENAME SMLMUSIC.BMP",;
  129.          Top          4.55,;
  130.          Left          1.19,;
  131.          Height          3.79
  132.  
  133.    DEFINE OKBUTTON SEARCHOKBUTTON OF THIS;
  134.        PROPERTY;
  135.          Width         14.11,;
  136.          Top          6.50,;
  137.          Left         28.56,;
  138.          Height          1.50
  139.  
  140.    DEFINE CANCELBUTTON SEARCHCANCELBUTTON OF THIS;
  141.        PROPERTY;
  142.          Group .F.,;
  143.          Width         14.11,;
  144.          Top          6.50,;
  145.          ID          0,;
  146.          Left         44.20,;
  147.          Height          1.50
  148.  
  149.    ****************************************************************************
  150.    procedure OnOpen
  151.    ****************************************************************************
  152.    set procedure to music.prg additive
  153.    do SetEnvironment
  154.    set exact off
  155.    form.tempIsOpen = .f.                   && necessary for knowing if temp
  156.                                            && table is in use at closing time
  157.    *******************************************************************************
  158.    procedure OnSelection
  159.  
  160.    * Search for the record where searchField = searchValue
  161.    * This procedure is called when the OK button is pressed in the Search form.
  162.    *******************************************************************************
  163.    param  controlId
  164.    private curTable,formName,field,value,searchForm,foundRecord,saveFilt,tagNo
  165.  
  166.    field = ALLTRIM(this.fieldCombo.value)            && searchField
  167.    value = ALLTRIM(this.valueEntry.value)            && searchValue
  168.    saveFilt = setto("filter")
  169.    set filter to
  170.    do case
  171.       case controlId = 0    && Cancel was selected.  Don't do anything
  172.          if form.tempIsOpen
  173.             use in temp
  174.          endif
  175.          this.Close()
  176.       case empty(field)
  177.          AlertMessage("No Field was selected, Try again","Alert")
  178.       case empty(value)
  179.          AlertMessage("No Value was specified, Try again", "Alert")
  180.       otherwise
  181.          curTable = alias()
  182.          if .not. form.tempIsOpen
  183.             use (curTable) in select() again alias temp
  184.             form.tempIsOpen = .t.
  185.          endif
  186.          select temp
  187.          set filter to &saveFilt && Same filter as main table
  188.          go top
  189.          *** convert value to type of key()
  190.          value = iif(type(field) $ "NF",val(value),value)
  191.          tagNo = tagno(field)
  192.          if tagNo <> 0 .and. key(tagNo) = field     && Tag for field exists
  193.             set order to &field  && Tags based on single field have field name
  194.             seek value
  195.          else
  196.             locate for &field = value
  197.          endif
  198.          *** convert back to character type if necessary
  199.          value = ALLTRIM(this.valueEntry.value)   &&iif(type("value") $ "NF", str(value),value)
  200.          foundRecord = recno()
  201.          if .not. found()
  202.             select &curTable
  203.             if ConfirmationMessage(FormatStr("%1 %2 not found. Continue Search?",;
  204.                                              proper(field),value),;
  205.                                     "Confirmation") = NO
  206.                use in temp
  207.                this.Close()
  208.             endif
  209.          else
  210.             select &curTable
  211.             go foundRecord
  212.             set message to FormatStr("%1 %2 was found.", proper(field),value)
  213.             use in temp
  214.             this.Close()
  215.          endif
  216.    endcase
  217.  
  218. ENDCLASS
  219.  
  220.  
  221.  
  222.